package cn.gov.msa.util;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;


public class JsonDate extends JsonDeserializer<Date> {  
	  

	@Override
	public Date deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");                 
        try {  
        	String date = p.getText(); 
            return format.parse(date);  
        } catch (Exception e) {  
            throw new RuntimeException(e);  
        }  
		
	}  
  
}  
